﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_CM_GetClientsByStaff]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_CM_GetClientsByStaff];
GO
CREATE PROCEDURE [dbo].[sproc_CM_GetClientsByStaff]
@staffid int

AS

    SELECT UDS_CM_ClientInfo.*,convert(nvarchar(10),UDS_CM_ClientInfo.UpdateTime,120) as updatetime1,UDS_CM_Linkman.Name AS Linkman FROM UDS_CM_ClientInfo LEFT JOIN UDS_CM_Linkman 
    ON UDS_CM_Linkman.ID=ChiefLinkmanID
    WHERE AddManID=@staffid 
    ORDER BY UpdateTime DESC